﻿using System.Runtime.Serialization;
using System.Windows.Media.Media3D;

namespace GameBoard
{
    [DataContract]
    public class ModelVisualData : BaseVisualData, IObjectFileData
    {
        [DataMember] private Point3D _centerOfModel;

        [DataMember]
        public Point3D Origin { get; set; }

        [DataMember]
        public double LongestSize { get; set; }

        [DataMember]
        public Point3D Location
        {
            get { return _centerOfModel; }
            set { _centerOfModel = value; }
        }

        [DataMember]
        public double VerticalPosition { get; set; }

        public TranslateTransform3D TranslateTransform
        {
            get
            {
                var translateTransform = new TranslateTransform3D(_centerOfModel.X, _centerOfModel.Y,
                                                                  _centerOfModel.Z + VerticalPosition);
                return translateTransform;
            }
        }

        public RotateTransform3D RotateTransform
        {
            get
            {
                var rotateTransform =
                    new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), Angle));
                return rotateTransform;
            }
        }

        public ScaleTransform3D ScaleTransform
        {
            get
            {
                var scaleTransform = new ScaleTransform3D(Scale, Scale, Scale);
                return scaleTransform;
            }
        }

        [DataMember]
        public string ObjectFile { get; set; }

        [DataMember]
        public double Angle { get; set; }

        [DataMember]
        public double Scale { get; set; }

        [DataMember]
        public bool OverrideDefaultMaterialFile { get; set; }
    }
}